package org.suk.dp.strategy;

/**
 * Description:返利收费子类 <br/>
 * @version V1.0  2017/6/20 12:27  by 石冬冬(dongdong.shi@ucarinc.com) - Heil Hitler
 */
public class CashReturn extends CashSuper {
    /**
     * 返利收费，初始化时必须要输入返利条件 和 返利值，比如满300返100，则moneyCondition为300，moneyReturn 为100；
     */
    private double moneyCondition = 0.0;
    private double moneyReturn = 0.0;

    public CashReturn(double moneyCondition, double moneyReturn) {
        this.moneyCondition = moneyCondition;
        this.moneyReturn = moneyReturn;
    }

    @Override
    double acceptCash(double money) {
        double result = money;
        if(money >= this.moneyCondition){
            result = money - Math.floor(money / this.moneyCondition) * this.moneyReturn;
        }
        return result;
    }
}
